from itertools import count

def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

def closest_prime(word1, word2, word3):
    word_to_num = {
        'zero': 0, 'one': 1, 'two': 2, 'three': 3,
        'four': 4, 'five': 5, 'six': 6, 'seven': 7,
        'eight': 8, 'nine': 9
    }

    num_str = ''.join(map(lambda x: str(word_to_num.get(x)), [word1, word2, word3]))

    if not num_str.isdigit() or len(num_str) != 3:
        return "Неправильный ввод"

    n = int(num_str)

    for i in count(n):
        if is_prime(i):
            return i